<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>轩盛金融</title>
    <meta name="keywords" content="轩盛金融">
    <meta name="description" content="轩盛金融">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__CSS__/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="__JS__/layui/css/layui.css"rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>所有表单元素 <small>包括自定义样式的复选和单选按钮</small></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link" href="product">
                                <i class="fa fa-reply"></i>
                            </a>

                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" action="{:url('Goods/interfacesChange')}" class="form-horizontal " enctype="multipart/form-data">
                        {volist name="formData" id="fd"}
                            <div class="form-group">
                                <label for="name" class="col-sm-3 control-label">商品名称</label>

                                <div class="col-sm-6">
                                    <input type="text" lay-verify="required" id="name" name="name" class="form-control" value="{$fd.name}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">商品类型</label>
                                <div class="col-sm-6">
                                    <select value="{$fd.cat_id}" lay-filter="select" lay-verify="required" class="form-control m-b" name="cat_id">
                                       
                                        {volist name="list" id="vo"}
                                            <option value="{$vo.cat_id}">{$vo.cat_name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>

                          <!--   <div class="hr-line-dashed"></div>

                             <div class="form-group">
                                <label class="col-sm-3 control-label">产品分类 <p style="color: red;">*必填</p></label>

                                <div class="col-sm-6">

                                    <select  lay-filter="select" lay-verify="required" class="form-control m-b" name="stair" onchange = "search(this)" id="classlist1">

                                        <option value="0" selected="selected">请选择商品一级分类</option>
 
                                    </select>

                                    <select  lay-filter="select" class="form-control m-b" lay-verify="required" name="second_level" onchange = "search2(this)"  id="classlist2">

                                        <option value="0" selected="selected">请选择商品二级分类</option>
 
                                    </select>

                                    <select  lay-filter="select" class="form-control m-b" lay-verify="required" name=" three_level" id="classlist3">

                                        <option value="0" selected="selected">请选择商品三级分类</option>
 
                                    </select>
                                </div>
                            </div>
 -->
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="cat_pic" class="col-sm-3 control-label">标的商品图片</label>
                                <div id="photo_box">
                                    {if condition="$formData[0]['pic']"}  
                                        <div class="col-sm-6">
                                            <img width="100px;" src="{$fd.pic}" alt="标的分类图片">
                                            <button id="change_photo" class="btn btn-warning pull-right">更改图片</button>
                                        </div>
                                    {else/}
                                        <div class="col-sm-6">
                                            <input type="file" lay-verify="required" id="pic" name="pic" class="form-control" accept="image/*">
                                        </div>
                                    {/if}    
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="aga">年龄要求</label>
                                <div class="col-sm-6">
                                    <div class="input-group m-b">
                                        <input type="text" name="aga" class="form-control" value="{$fd.aga}"> <span class="input-group-addon">岁</span>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="price">产品额度</label>
                                <div class="col-sm-6">
                                    <div class="input-group m-b">
                                        <input type="text" name="price" class="form-control" value="{$fd.price}"> <span class="input-group-addon">万</span>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="introduce">产品简介</label>

                                <div class="col-sm-6">
                                    <input type="type" lay-verify="required" value="{$fd.introduce}" id="introduce" name="introduce" class="form-control">
                                </div>
                            </div>
                         <!--    
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">放款时间</label>
                                <div class="col-sm-6">

                                    <input type="text" name="time" class="form-control" value="{$fd.time}">
                    
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="platform_fee">一次性平台费/保险费</label>
                                <div class="col-sm-6">

                                    <input type="text" name="platform_fee" class="form-control" value="{$fd.platform_fee}">
                    
                                </div>
                            </div>
                            

                            

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="job_information">工作信息</label>

                                <div class="col-sm-6">
                                    <input type="type" id="job_information" name="job_information" class="form-control" value="{$fd.job_information}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">保单缴费次数 / 供房记录</label>

                                <div class="col-sm-6">
                                    <textarea name="loan_multiples_requirements" style="resize:none" class="form-control" rows="8">{$fd.loan_multiples_requirements}</textarea>
                                </div>
                            </div>
                    
                            
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="settle">结清</label>

                                <div class="col-sm-6">
                                    <input type="type" id="settle" name="settle" class="form-control" value="{$fd.settle}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="overpayment">复效、超缴费日期</label>

                                <div class="col-sm-6">
                                    <input type="type" id="overpayment" name="overpayment" class="form-control" value="{$fd.overpayment}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="know">配偶是否知情</label>

                                <div class="col-sm-6">
                                    <input type="type" id="know" name="know" class="form-control" value="{$fd.know}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="inspect">是否上门考察</label>

                                <div class="col-sm-6">
                                    <input type="type" id="inspect" name="inspect" class="form-control" value="{$fd.inspect}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="hang">挂靠单位</label>

                                <div class="col-sm-6">
                                    <input type="type" id="hang" name="hang" class="form-control" value="{$fd.hang}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="credit_investigation">征信查询次数</label>

                                <div class="col-sm-6">
                                    <input type="type" id="credit_investigation" name="credit_investigation" class="form-control" value="{$fd.credit_investigation}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="credit">征信显示</label>

                                <div class="col-sm-6">
                                    <input type="type" id="credit" name="credit" class="form-control"  value="{$fd.credit}">
                                </div>
                            </div>
 -->
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" for="container">产品详情</label>

                                <div class="col-sm-6">
                                    <script id="container" name="content" type="text/plain"></script>
                                </div>
                            </div>

                            <input type="hidden" name="goods_type" value="1">
                            <input type="hidden" name="id" value="{$fd.id}">


                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-2 col-sm-offset-7">
                                    <button lay-submit lay-filter="upload" class="btn btn-primary btn-block" type="submit">保存内容</button>
                                    
                                </div>
                            </div>
                        {/volist}    
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="__JS__/jquery.min.js?v=2.1.4"></script>
    <script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
    <script src="__JS__/plugins/ueditor/ueditor.config.js"></script>
    <script src="__JS__/plugins/ueditor/ueditor.all.js"></script>
    <script src="__JS__/layui/layui.js"></script>
    <script>
    
    // 富文本赋值
        function UeValue(ueName,ueValue){
            this.ueName = ueName;
            this.ueValue = ueValue;
        }
        UeValue.prototype.value = function(){
            // 保存后台传的数据
            // this -> 正在调用的对象(全局)
            var value = this.ueValue;

            // this -> 正在调用的对象(全局)
            this.ueName.ready(function(){
                // this - > ueName (不再是全局,是在 ueName 内部)
                this.setContent(value);    
            })
            
        }


    // 富文本设置
        var editor = UE.getEditor('container',{
            toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'emotion', 'scrawl','insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help'
        ]],
        autoHeightEnabled:true,
        initialFrameHeight:400
        });

    // 从后端获取数据,并赋值到 Ueditor 
        var getUeValue = new UeValue(editor,'<?php echo $formData[0]["content"];?>');
        getUeValue.value();

        
        // 引用layui
        layui.use(['layer', 'form'], function(){
          var layer = layui.layer;
          var form = layui.form;
        });

        $('#change_photo').on('click',function(event){
            event.preventDefault();
            $('#photo_box').html(
                '<input class="col-sm-6" lay-verify="required" type="file" id="pic" name="pic" accept="image/*"/>'
            );
        })


             $(function(){

            $.ajax({

                type:"POST",
                
                url:"goodsCatAdd", 

                success:function(data){

                console.log(data);   

                var html="";

                $.each(data,function(i,v){
                    console.log(v);



                    html+=`
                        
                        <option value="${v.id}">${v.name}</option>;


                    `;


                })
                 $('#classlist1').append(html);
                },
                async:true
            });


        })



          function search(event){

                // 获取用户填写的验证码

                // var giveGoods = event;

                var giveGoods = $(`#classlist1 option:selected`).val();

                  console.log(giveGoods);

                $.ajax({

                    type:"post",

                    url:"goodsCatAdd",

                    data:'id='+giveGoods,

                      success:function(data){

                    var html="";

                    var html1="";

                    console.log(data);

                $.each(data,function(i,v){

                    console.log(v);

                    html+=`
                        
                        <option value="${v.id}">${v.name}</option>;

                    `;



                })
                    html1+=`

                     <option value="0" selected="selected">请选择商品二级分类</option>;
                    `;

                 $('#classlist2').html(html1);
                 $('#classlist2').append(html);
                 },
                        async:true
                    });
                };



              function search2(event){

                // 获取用户填写的验证码

                // var giveGoods = event;

                var giveGoods = $(`#classlist2 option:selected`).val();

                  console.log(giveGoods);

                $.ajax({

                    type:"post",

                    url:"goodsCatAdd",

                    data:'id='+giveGoods,

                      success:function(data){

                    var html="";

                    var html1="";

                    console.log(data);

                $.each(data,function(i,v){

                    console.log(v);

                    html+=`
                        
                        <option value="${v.id}">${v.name}</option>;

                    `;

                })
                    html1+=`

                     <option value="0" selected="selected">请选择商品三级分类</option>;
                    `;

                 $('#classlist3').html(html1);

                 $('#classlist3').append(html);

                 },
                        async:true
                    });
                };
    </script>
</body>

</html>
